<template>
  <div id="app">
    <router-view  v-if="reload"/>
  </div>
</template>
<script>
import Cookies from "js-cookie";
export default {
  data(){
    return{
      routerName:"",
      reload:true
    }
  },
  watch:{
    "$route":{
      handler(to,from){
        let toName = to.name
        const toIndex = to.meta.index
        const fromIndex = from.meta.index
        this.transitionName = toIndex < fromIndex ? 'slide-right' : 'slide-left'
      }
    },
    '$store.state.sysLanguage':{
      handler(newVal){
        this.$store.commit('setSysLanguage',newVal)
        this.reload = false
        this.$nextTick(()=>{
          this.reload = true
        })
      }
    }
  },
  created(){
    if(Cookies.get('languages')){
      this.$store.commit('setSysLanguage',Cookies.get('languages'))
      return
    }
    let lanTemp = navigator.language
    switch (lanTemp) {
      case "zh":
        this.$store.commit('setSysLanguage',"zh_cn")
        break;
      case "en":
        this.$store.commit('setSysLanguage',"en_us")
        break;
      default:
        break;
    }
  },
  mounted(){
console.log(`%c
________  ________  ___       ________          ________  _________  ________  ________     
|\\  ____\\|\\   __  \\|\\  \\     |\\   ___ \\        |\\   ____\\|\\___   ___\\\\   __  \\|\\   __  \\
\\ \\ \\___|\\ \\  \\|\\  \\ \\  \\    \\ \\  \\_|\\ \\       \\ \\  \\___|\\|___ \\  \\_\\ \\  \\|\\  \\ \\  \\|\\  \\
\\ \\  \\    \\ \\  \\\\\\  \\ \\  \\    \\ \\  \\ \\\\ \\       \\ \\_____  \\   \\ \\  \\ \\ \\   __  \\ \\   _  _\\
 \\ \\  \\____\\ \\  \\\\\\  \\ \\  \\____\\ \\  \\_\\\\ \\       \\|____|\\  \\   \\ \\  \\ \\ \\  \\ \\  \\ \\  \\\\  \\|
  \\ \\_______\\ \\_______\\ \\_______\\ \\_______\\        ____\\_\\  \\   \\ \\__\\ \\ \\__\\ \\__\\ \\__\\\\ _\\
   \\|_______|\\|_______|\\|_______|\\|_______|       |\\_________\\   \\|__|  \\|__|\\|__|\\|__|\\|__|
                                                  \\|_________|
`,'color:#06b8de')
console.log('奥利给，干了')
  }
}
</script>
<style scoped>
.gg{
  font-weight: bold;
}
</style>
